/*
 * Copyright (c) Jan Šlahora (${USER}) - 2012.
 * Created in IntelliJ IDEA 10.5
 */

package statistics.Asonance;

import statistics.Samohlasky;
import statistics.tests.ATest;

import java.util.ArrayList;

/*
*   File IAsonance 
*   in package statistics.Asonance
*   was created by slaha
*   on 27.3.12 at 20:35.
*
*/


public abstract class IAsonance extends Samohlasky implements Runnable {

  protected ArrayList<String> texty;
  protected ATest aTest = new ATest();

  protected IAsonance() {
    super();
  }

  protected IAsonance(ArrayList<String> texty) {
    this.texty = texty;
  }

  protected synchronized ArrayList<Character> dejVokaly(char[] text) {
    ArrayList<Character> vokaly = new ArrayList<>();

    for (char c : text) {
      /*if (vokaly.size() >= 38) {
        break;
      }*/
      c = Character.toLowerCase(c);
      for (char samohlaska : samohlasky) {
        if (c == samohlaska) {
          vokaly.add(c);
          break;
        }
      }
    }

    return vokaly;
  }

  public ATest getaTest() {
    return aTest;
  }

  protected int getTheLongest(ArrayList<SpocitaniAsonance> al) {
    int max = -1;
    for (SpocitaniAsonance sa : al) {
      if (max < sa.getHodnoty().size()) {
        max = sa.getHodnoty().size();
      }
    }
    return max;
  }

  protected abstract class SpocitaniAsonance extends Thread {
    protected String text;
    protected ArrayList<Double> hodnoty = new ArrayList<>();
    public boolean hotovo = false;

    public SpocitaniAsonance(String text) {
      this.text = text;
    }

    public void spust() {
      run();
      hotovo = true;
    }

    protected ArrayList<Double> getHodnoty() {
      return hodnoty;
    }

    protected boolean isHotovo() {
      return hotovo;
    }
  };

}